<?php


namespace App\Admin\Controllers\Api;


use App\Models\User;
use Illuminate\Http\Request;

class ExpertController
{
    public function index(Request $request){

        $expert = User::where('role',2) -> where('service_catid',$request->input('q')) -> get(['id','user_name','real_name']);

        foreach($expert as $v){
            $v -> real_name && $v -> user_name = $v -> real_name;
            $v -> text = $v -> real_name ?: $v -> user_name;
            unset($v -> user_name,$v -> real_name);
        }

        return $expert;
    }

}